<?php
error_reporting (E_ALL ^ E_NOTICE);
@session_start();
require_once("../../includes/config.inc.php"); 
require_once("../../includes/Database.class.php"); 
$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); 
$db->connect(); 	
	
// Check the user has typed something in our input box.
if(isset($_POST['mysearchString'])) 
{
	$mysearchString = mysql_real_escape_string($_POST['mysearchString']);
	$sql = "SELECT * FROM tb_deviceinfo,tb_clientinfo WHERE di_status = 1 AND di_clientId=ci_id AND ci_id=".$_SESSION[clientID]." AND (di_deviceId like '$mysearchString%' or di_deviceName like '$mysearchString%' )";
	$rows = $db->query($sql);
	$tot=$db->affected_rows;
	// Is the string length greater than 0?
	
	if($tot > 0)
	{
		while ($record = $db->fetch_array($rows)) 
		{
	//		print_r($record);
			if($record[di_deviceName])
				$devName = $record[di_deviceName];
			else
				$devName = $record[di_deviceId];
			echo '<li onClick="fill(\''.$record[di_id]."#".$devName.'\');">'.$devName.'</li>';
		}
	} 
	else
	{
		// Dont do anything.
	} 
} 
?>